<?php
/**
 * Created by PhpStorm.
 * User: beijingwhg
 * Date: 2017/5/5
 * Time: 下午5:30
 */

namespace App\Http\Middleware;


use Closure;
use Illuminate\Contracts\Auth\Factory as Auth;

class AdminAuth
{
    protected $auth;

    public function __construct(Auth $auth)
    {
        $this->auth = $auth->guard('admin');
    }

    public function handle($request, Closure $next)
    {
        if (!$this->auth->check()) {
            $request->session()->put('intend',$request->getRequestUri());

            return redirect('/admin/login');
        }

        return $next($request);
    }
}